/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bio.jpa.entities;

import java.io.Serializable;
import java.util.List;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego
 */
@Entity
@Table(name = "audit_log", catalog = "biodb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AuditLog.findAll", query = "SELECT a FROM AuditLog a"),
    @NamedQuery(name = "AuditLog.findByIdLog", query = "SELECT a FROM AuditLog a WHERE a.idLog = :idLog"),
    @NamedQuery(name = "AuditLog.findByDescription", query = "SELECT a FROM AuditLog a WHERE a.description = :description"),
    @NamedQuery(name = "AuditLog.findByOldValue", query = "SELECT a FROM AuditLog a WHERE a.oldValue = :oldValue"),
    @NamedQuery(name = "AuditLog.findByNewValue", query = "SELECT a FROM AuditLog a WHERE a.newValue = :newValue"),
    @NamedQuery(name = "AuditLog.findByDate", query = "SELECT a FROM AuditLog a WHERE a.date = :date"),
    @NamedQuery(name = "AuditLog.findByDoneBy", query = "SELECT a FROM AuditLog a WHERE a.doneBy = :doneBy")})
public class AuditLog implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Basic(optional = false)
    @Column(name = "id_log")
    private Long idLog;
    @Size(max = 200)
    @Column(name = "description")
    private String description;
    @Size(max = 200)
    @Column(name = "old_value")
    private String oldValue;
    @Size(max = 200)
    @Column(name = "new_value")
    private String newValue;
    @Basic(optional = false)
    @NotNull
    @Column(name = "date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;
    @Size(max = 45)
    @Column(name = "done_by")
    private String doneBy;
    @ManyToMany(mappedBy = "auditLogList")
    private List<GenBank> genBankList;
    @ManyToMany(mappedBy = "auditLogList")
    private List<Project> projectList;

    public AuditLog() {
    }

    public AuditLog(Long idLog) {
        this.idLog = idLog;
    }

    public AuditLog(Long idLog, Date date) {
        this.idLog = idLog;
        this.date = date;
    }

    public Long getIdLog() {
        return idLog;
    }

    public void setIdLog(Long idLog) {
        this.idLog = idLog;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getOldValue() {
        return oldValue;
    }

    public void setOldValue(String oldValue) {
        this.oldValue = oldValue;
    }

    public String getNewValue() {
        return newValue;
    }

    public void setNewValue(String newValue) {
        this.newValue = newValue;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String getDoneBy() {
        return doneBy;
    }

    public void setDoneBy(String doneBy) {
        this.doneBy = doneBy;
    }

    @XmlTransient
    public List<GenBank> getGenBankList() {
        return genBankList;
    }

    public void setGenBankList(List<GenBank> genBankList) {
        this.genBankList = genBankList;
    }

    @XmlTransient
    public List<Project> getProjectList() {
        return projectList;
    }

    public void setProjectList(List<Project> projectList) {
        this.projectList = projectList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idLog != null ? idLog.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AuditLog)) {
            return false;
        }
        AuditLog other = (AuditLog) object;
        if ((this.idLog == null && other.idLog != null) || (this.idLog != null && !this.idLog.equals(other.idLog))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bio.jpa.entities.AuditLog[ idLog=" + idLog + " ]";
    }
    
}
